import { request } from '@umijs/max';
import { PageResponse, SourceEntity } from './index';

// 新增综艺节目请求
export interface VarietyShowInfoAddRequest {
  title: string;
  periodName: string;
  genre: string;
  releaseDate: string | null;
  period: number;
  sumPeriod: number;
  description: string;
  tags: string;
  poster: number | null;
  playSourceInfo: SourceEntity[];
  status: string;
  famousPersonId: number;
  language: string;
}

// 更新综艺节目请求
export interface VarietyShowInfoUpdateRequest extends VarietyShowInfoAddRequest {
  id: number;
}

// 综艺节目详情
export interface VarietyShowInfoDetail {
  id: number;
  title: string;
  periodName: string;
  genre: string;
  releaseDate: string;
  period: number;
  sumPeriod: number;
  description: string;
  tags: string;
  poster: number;
  playSourceInfo: SourceEntity[];
  status: string;
  famousPersonId: number;
  language: string;
}

// 分页查询请求
export interface VarietyShowInfoPageRequest {
  pageCurrent: number;
  pageSize: number;
  keyword?: string;
  status?: string;
  famousPersonId: number;
}

// 添加综艺节目
export async function addVarietyShowInfo(data: VarietyShowInfoAddRequest) {
  return request('/variety-show-info/back', {
    method: 'POST',
    data,
  });
}

// 更新综艺节目
export async function updateVarietyShowInfo(data: VarietyShowInfoUpdateRequest) {
  return request('/variety-show-info/back', {
    method: 'PUT',
    data,
  });
}

// 删除综艺节目
export async function deleteVarietyShowInfo(idList: number[]) {
  const ids = idList.join(',');
  return request(`/variety-show-info/back/${ids}`, {
    method: 'DELETE',
  });
}

// 分页查询
export async function getVarietyShowInfoPage(params: VarietyShowInfoPageRequest) {
  return request<PageResponse<VarietyShowInfoDetail>>('/variety-show-info/page', {
    method: 'POST',
    data: params,
  });
}

// 获取综艺节目详情
export async function getVarietyShowInfoDetail(id: number) {
  return request<VarietyShowInfoDetail>(`/variety-show-info/${id}`, {
    method: 'GET',
  });
}

// 添加状态枚举
export const VARIETY_SHOW_STATUS = {
  ALL: { label: '全部', value: '' },
  WAITING_PLAY: { label: '待播', value: 'WAITING_PLAY' },
  PLAYING: { label: '在播', value: 'PLAYING' },
  FINISHED: { label: '已完结', value: 'FINISHED' },
  UNKNOWN: { label: '未知', value: 'UNKNOWN' },
}; 